package relation;

import cn.moukou.dictator.ServerApplication;
import cn.moukou.dictator.dao.node.KVNodeDAO;
import cn.moukou.dictator.dao.relation.KVNODE_RELATION_DAO;
import cn.moukou.dictator.dao.relation.STUDENT_ACTIVITY_DAO;
import cn.moukou.dictator.pojo.node.KVNode;
import cn.moukou.dictator.pojo.relation.KVNODE_RELATION;
import cn.moukou.dictator.pojo.relation.STUDENT_ACTIVITY;
import net.bytebuddy.asm.Advice;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.ArrayList;
import java.util.List;

@SpringBootTest(classes = ServerApplication.class)
public class STUDENT_ACTIVITY_TEST {
    @Autowired
    STUDENT_ACTIVITY_DAO relationDao;
    @Autowired
    KVNODE_RELATION_DAO kvRelationDao;
    @Autowired
    KVNodeDAO kvDAO;

    @Test
    public void addRelation() {
        KVNode start = kvDAO.customFindByStudentName("冯璐");
        List<String> namaList = new ArrayList<>();
//        namaList.add("校园足球联赛决赛 ");
        namaList.add("省博览会志愿者");
//        namaList.add("济南市盲聋学校志愿者");
//        namaList.add("新生杯篮球赛决赛");
//        namaList.add("健康·阳光 校园心理剧大赛");
//        namaList.add("老校友代表座谈会组织工作");
//        namaList.add("校运动会羽毛球比赛");
//        namaList.add("世界遗产青年保卫者");
        namaList.add("校园十佳歌手歌唱比赛 ");
        namaList.add("校运动会团体操表演");
        namaList.add("星海环保论坛志愿者");

        for(int i = 0; i < namaList.size(); ++i) {
            STUDENT_ACTIVITY relation = new STUDENT_ACTIVITY();
            KVNode end = kvDAO.customFindByActivityName(namaList.get(i));

            relation.setStartNode(start);
            relation.setEndNode(end);
            relationDao.save(relation);
        }
    }

    @Test
    public void addKVNODE_RELATION() {
        Iterable<STUDENT_ACTIVITY> it = relationDao.findAll();
        for (STUDENT_ACTIVITY st_ac : it) {
            System.out.println(st_ac);
            KVNODE_RELATION kvRelation = new KVNODE_RELATION();
            kvRelation.setStartNode(st_ac.getStartNode());
            kvRelation.setEndNode(st_ac.getEndNode());
            kvRelation.setRelationType("student_activity");
            kvRelation.setRelationLabel("st_ac");
            kvRelationDao.save(kvRelation);
        }
    }

}
